package Controller.Actions.Add;

import Controller.*;
import java.io.*;
import java.net.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import Model.Beans.Results.*;
import Model.Beans.*;
import Model.QBE.*;

public class AddScheduleAction implements Action {
    
    private String name;
    public AddScheduleAction() 
    {
        this.name = "AddSchedule";
    }
    
    public String getName()
    {
        return name;
    }
    
    public void perform(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    {
        ScheduleModel smodel = new ScheduleModel();
        String student_id = request.getParameter("student_id");
        String course_id = request.getParameter("course_id");
        
        Schedule schedule = new Schedule(Integer.parseInt(student_id), Integer.parseInt(course_id));
        
        response.setContentType("text/xml");
        response.setHeader("Cache-Control", "no-cache");
        
        if(smodel.insert(schedule) != 0)
        {
            response.getWriter().write("<message>true</message>");
        }
        else
        {
           response.getWriter().write("<message>false</message>");
        }
    }
    
}
